﻿using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DevGrid
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        string[] name =
           { "序号", "采集时间" ,"前称结果","电芯Barcode" ,"上料扫码结果","CCD结果", "注液量","OK/NG", "称类型", "注液时间(S)" ,
             "注液真空" ,"漏检后真空值" , "真空保压时间300ms","气密性0=OK:1=NG","杯体号","电池复检纠偏值","电池X坐标" ,"电池Y坐标","成品编号",
             "机台号","操作员工","生产型号","电解液批次号","上料托盘","前称编号","前称读数","后称编号" ,"后称读数" ,"下料条码" ,
            "下料扫码结果" ,"注液号" ,"漏检抽真空值" ,"电池纠偏值" ,"真空保压时间600ms" ,"真空保压时间900ms" ,"真空保压时间1200ms" ,"真空保压时间1500ms" ,"真空保压时间1800ms" ,"规格上限" ,
            "规格下限" ,"成品批次" ,"导出否" ,"下料完成否" ,"下料原因","组合数据"};
        int[] headerLength = { 60, 150, 100, 250, 100, 100, 100, 100, 80, 100,100, 100,
                100, 100, 100, 100, 100, 100,100,100, 60, 100, 100, 100, 100, 100, 100
            ,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100,100};

        private void Form1_Load(object sender, EventArgs e)
        {
            devGridView1.C_MaxRowCount = 50;
            //for (int k = 0; k < name.Length; k++)
            //{
            //    devGridView1.C_CollumnsAdd(name[k],typeof(string), headerLength[k]);
            //}
        }

        int k = 0;
        private void button2_Click(object sender, EventArgs e)
        {
            name[0] = k++.ToString();
            devGridView1.C_AddNewRow(name);
        }



        DataTable dtUser = new DataTable();
        DataTable dtDND = new DataTable();
        private void button1_Click(object sender, EventArgs e)
        {
    
        }

        private void button3_Click(object sender, EventArgs e)
        {
            dtUser.Columns.Add("username", System.Type.GetType("System.String"));
            dtUser.Columns.Add("age", System.Type.GetType("System.String"));
            dtUser.Columns.Add("age1", System.Type.GetType("System.String"));
            //dtUser.Rows.Add("张三", "123");
            //dtUser.Rows.Add("李四", "11223");
            //dtUser.Rows.Add("王五", "11223");
            devGridView1.DataTable = dtUser;
            dtDND.Columns.Add("age", System.Type.GetType("System.String"));
            dtDND.Columns.Add("age1", System.Type.GetType("System.String"));
            dtDND.Columns.Add("age2", System.Type.GetType("System.String"));
            dtDND.Rows.Add("张三", "123");
            dtDND.Rows.Add("李四", "11223");
            dtDND.Rows.Add("王五", "000");
  
        }

        private void button4_Click(object sender, EventArgs e)
        {
            devGridView1.DataTable = dtDND;
        }

        private void button5_Click(object sender, EventArgs e)
        {
            //dtUser.Rows.Add("张三", "123");
            devGridView1.DataTable = dtUser;
        }

        private void button6_Click(object sender, EventArgs e)
        {
            dtDND.Rows.Add("张三", "123");
        }

        private void button7_Click(object sender, EventArgs e)
        {
            dtDND.Rows[dtDND.Rows.Count-1].Delete();
        }
    }
}
